﻿using IServices;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Diagnostics;
using ViewModel.AccountModel;
using ViewModel.Response;

namespace Management.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class AccountController : BaseController
    {
        private IAccountService accountService;
        public AccountController(
            ILogger<AccountController> logger,
            IAccountService accountService) : base(logger)
        {
            this.accountService = accountService;
        }
        /// <summary>
        /// 获取所有用户
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel<IEnumerable<Account>> GetAllAccount()
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            var result = new ResponseModel<IEnumerable<Account>>
            {
                Data = accountService.GetAccounts(),
                Status = ResponseStatus.OK
            };
            stopwatch.Stop();
            logger.LogInformation($"Account执行时间为: {stopwatch.Elapsed.TotalMilliseconds}");
            return result;
        }


        [HttpPost]
        public ResponseModel<string> AddAccount()
        {
            var result = new ResponseModel<string>
            {

            }; 
            return result;
        }

    }
}